package cn.lger.icollege.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * Code that Changed the World
 * Pro said
 * Created by Pro on 2018-05-05.
 */
@Entity
@Setter
@Getter
public class AttendanceRecord {

    @Id
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    private String id;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createDate;

    private String customerName = " ";

    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnore
    private Classroom classroom;

    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnore
    private Teacher teacher;

    @OneToMany(cascade = CascadeType.REMOVE, mappedBy = "record")
    @OrderBy("student.username")
    private List<Attendance> attendances;
}
